﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.ComponentModel;

namespace SilverlightDragDrop
{
  public class StringToGroupsConverter: TypeConverter
  {
    public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
    {
      var groups = new GroupCollection();
      groups.Add(new Group() { Content = value.ToString() });
      return groups;
    }


    public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
    {
      return sourceType == typeof(String);
    }

    // CanConvertTo and ConvertTo are not required for Silverlight - keep default implementation

    public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
    {
      return base.CanConvertTo(context, destinationType);
    }

    public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
    {
      return base.ConvertTo(context, culture, value, destinationType);
    }
  }
}
